package com.zbkj.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.zbkj.admin.mapper1.EbDividendConfigMaper;
import com.zbkj.admin.mapper1.EbDividendRecordMapper;
import com.zbkj.admin.pojo.EbDividendConfigEntity;
import com.zbkj.admin.pojo.EbDividendRecordEntity;
import com.zbkj.admin.service.EbDividendConfigService;
import com.zbkj.admin.service.EbDividendRecordService;
import net.dreamlu.mica.core.result.R;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 商户分红期数记录
 */
@Service
public class EbDividendConfigServiceImpl extends ServiceImpl<EbDividendConfigMaper, EbDividendConfigEntity> implements EbDividendConfigService {

    // 查询提现手续费
    @Override
    public BigDecimal getHandFee() {
        List<EbDividendConfigEntity> list = list(from().orderBy(EbDividendConfigEntity::getCreatedTime, false));
        if(list != null && list.size() > 0) {
            EbDividendConfigEntity config = list.get(0);
            return config.getHandFee() != null && config.getHandFee().compareTo(BigDecimal.ZERO) > 0 ? config.getHandFee() : BigDecimal.ZERO;
        }
        return BigDecimal.ZERO;
    }

}
